# Contributor: Holger Jaekel <holger.jaekel@gmx.de>
# Maintainer: Holger Jaekel <holger.jaekel@gmx.de>
pkgname=cfitsio
pkgver=4.3.1
pkgrel=0
pkgdesc="Library reading and writing data files in Flexible Image Transport System data format"
url="https://heasarc.gsfc.nasa.gov/fitsio/"
arch="all"
license="custom"
makedepends="
	bzip2-dev
	curl-dev
	gfortran
	"
subpackages="
	$pkgname-static
	$pkgname-dev
	"
source="
	https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/cfitsio-$pkgver.tar.gz
	10-OFF_T.patch
	"

build() {
	./configure \
		--prefix=/usr \
		--with-bzip2 \
		--enable-reentrant \
		--enable-sse2 \
		--enable-hera
	make shared
	make utils
}

package() {
	make DESTDIR="$pkgdir" install
	mkdir -p "$pkgdir"/usr/share/licenses/cfitsio/
	cp License.txt "$pkgdir"/usr/share/licenses/cfitsio/

	# delete test/demo programs
	rm "$pkgdir"/usr/bin/testprog
	rm "$pkgdir"/usr/bin/cookbook

	# avoid conflicts with smem
	rm "$pkgdir"/usr/bin/smem
}

check() {
	LD_LIBRARY_PATH=. ./testprog > testprog.lis
	[ -z $(diff testprog.lis testprog.out) ]
	[ -z $(cmp testprog.fit testprog.std) ]
}

sha512sums="
7c1800c8741afc55c243c54bf9500e9f512305bcafc82267eca83acb568828f3c7d629550ccc61c9edf8b980efda61caef3feb229aba8aef1b100804aaaa7ae5  cfitsio-4.3.1.tar.gz
5b5a2f932e837a86ae4dd4cf035c2a0ee27c27b7f06f24375ef29312c8836f03d688c66e3cdf19b4617859f9845f602d13017a8564803408eec9d7f928ced6bc  10-OFF_T.patch
"
